﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XcoAppSpaces.Contracts.Serialization;
using XcoAppSpaces.Contracts.Service;
using XcoAppSpaces.Contracts.Transport;

namespace XcoAppSpaces.Core
{
	/// <summary>
	/// Defines general configuration extensions (which are not specific to a certain service implementation).
	/// </summary>
	public static class GeneralFluentConfigExtensions
	{
		/// <summary>
		/// Defines a certain serializer to be used with the given transport service.
		/// </summary>
		/// <typeparam name="T">The type of the transport service.</typeparam>
		/// <param name="config">The configuration object.</param>
		/// <param name="serializerName">The name of the serializer to be mapped with the transport service.</param>
		/// <returns>The configuration object for further configuration with the fluent interface.</returns>
		public static XcoFluentServiceConfig<T> WithSerializer<T>(this XcoFluentServiceConfig<T> config, string serializerName)
			where T : IXcoTransportService
		{
			config.ServiceConfig.AddMapping(typeof(IXcoSerializer), serializerName);
			return config.FluentConfig;
		}
	}
}
